package com.jing.mapper;

import com.jing.pojo.ReadingRooms;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 陈书憬
 * @version 1.0
 * 2024/9/17
 */
@Mapper
public interface ReadingRoomsMapper {

    List<ReadingRooms> list(String name, String type);

    @Select("select * from reading_rooms;")
    List<ReadingRooms> categoryList();

    @Insert("insert into reading_rooms(name, type, floor,seat_num, area, open_time, close_time, image_url,created_time, updated_time,is_set) " +
            "values(#{name}, #{type}, #{floor}, #{seatNum}, #{area}, #{openTime}, #{closeTime}, #{imageUrl},#{createdTime}, #{updatedTime},#{isSet})")
    void add(ReadingRooms readingRooms);

    @Update("update reading_rooms set name=#{name}, type=#{type}, floor=#{floor}, seat_num=#{seatNum}, area=#{area}, open_time=#{openTime}, close_time=#{closeTime}, image_url=#{imageUrl},updated_time=#{updatedTime} where id=#{id};")
    void update(ReadingRooms readingRooms);

    @Delete("delete from reading_rooms where id=#{id};")
    void deleteById(Integer id);

    @Update("update reading_rooms set is_active=#{state} where id=#{id};")
    void updateState(Long id, Boolean state);

    @Update("update reading_rooms set is_set=#{state} where id=#{id};")
    void updateIsSet(Long id, Boolean state);

    @Select("select * from reading_rooms;")
    List<ReadingRooms> listNoPage();


    @Select("select id from reading_rooms where name=#{name};")
    int getRoomId(String name);

    @Select("select * from reading_rooms where name=#{name};")
    List<ReadingRooms> selectName(String name);
}
